package cn.itcast.daoTest;


import cn.itcast.dao.OrdersMapper;
import cn.itcast.domain.Orders;
import cn.itcast.domain.OrdersUser;
import cn.itcast.domain.User;
import cn.itcast.domain.UserOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/applicationContext-*.xml"})
public class OrderMapperDaoTest {

    @Autowired
    private OrdersMapper ordersMapper;

    @Test
    public void saveOrders(){

        Orders orders = new Orders();
        orders.setUserId(1);
        orders.setNumber("17803878933");
        orders.setCreatetime(new Date());
        orders.setNote("你好");
        ordersMapper.saveOrders(orders);

    }


    @Test
    public void getOrderList(){
        ordersMapper.getOrderList();
    }


    @Test
    public void getOrdersUserTest(){
        List<OrdersUser> ordersUser = ordersMapper.getOrdersUser();
        System.out.println(ordersUser);
    }

    @Test
    public void getOrdersUser2Test(){
        List<OrdersUser> ordersUser2 = ordersMapper.getOrdersUser2();
        System.out.println(ordersUser2);
    }

    @Test
    public void getUserOrderTest(){
        List<User> userOrder = ordersMapper.getUserOrder();
        System.out.println(userOrder);

    }

    @Test
    public void getUserOrder2Test(){
        List<UserOrder> userOrder2 = ordersMapper.getUserOrder2();
        System.out.println(userOrder2);

    }

}
